package 算法.NiuKe;

import java.util.ArrayList;

/**
 * @author:谢君臣
 * @Date:2021/10/9-16:54
 * @version:1.0
 * @function:
 */
public class 二叉树构建 {
    public static void main(String[] args) {
        solve(new int[]{1,2,4,5,3,6,7},new int[]{4,2,5,1,6,3,7});
    }
    public static int[] solve (int[] xianxu, int[] zhongxu) {
        // write code here
        ArrayList<Integer> left = new ArrayList<>();
        ArrayList<Integer> right = new ArrayList<>();
        int mid = Integer.MAX_VALUE,root=xianxu[0];
        for (int i = 0; i < zhongxu.length; i++) {
            if (root==zhongxu[i]){
                mid=i;
                continue;
            }
            if (i<mid) left.add(zhongxu[i]);
            else right.add(zhongxu[i]);
        }
        TreeNode treeNode = function(xianxu,left,right);
        return null;
    }

    private static TreeNode function(int[] xianxu, ArrayList<Integer> left, ArrayList<Integer> right) {

        return null;
    }
}
